package bus;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

public class Year {
	private Integer year;
	private GregorianCalendar calendar;
	private List<Month> months;
	
	public Year() {
	}
	
	public Year(GregorianCalendar calendar, Integer year) {
		this.calendar = calendar;
		this.year = year;		
		
		this.populateMonths();
	}
	
	private void addMonth(Month month) {
		if (this.months != null) {
			this.months.add(month);
		}
	}
	
	private void populateMonths() {
		this.months = new ArrayList<Month>();
		
		// NOTE:  The months are hard-coded at this point because I'm only developing towards
		// the GregorianCalendar.
		// TODO:  Compensate for different types of calendars.
		for (Integer i = 0; i <= this.calendar.getActualMaximum(Calendar.MONTH); i++) {
			switch (i) {
				case Calendar.JANUARY:
					this.addMonth(new Month(this, Calendar.JANUARY));
					break;
				case Calendar.FEBRUARY:
					this.addMonth(new Month(this, Calendar.FEBRUARY));
					break;
				case Calendar.MARCH:
					this.addMonth(new Month(this, Calendar.MARCH));
					break;
				case Calendar.APRIL:
					this.addMonth(new Month(this, Calendar.APRIL));
					break;
				case Calendar.MAY:
					this.addMonth(new Month(this, Calendar.MAY));
					break;
				case Calendar.JUNE:
					this.addMonth(new Month(this, Calendar.JUNE));
					break;
				case Calendar.JULY:
					this.addMonth(new Month(this, Calendar.JULY));
					break;
				case Calendar.AUGUST:
					this.addMonth(new Month(this, Calendar.AUGUST));
					break;
				case Calendar.SEPTEMBER:
					this.addMonth(new Month(this, Calendar.SEPTEMBER));
					break;
				case Calendar.OCTOBER:
					this.addMonth(new Month(this, Calendar.OCTOBER));
					break;
				case Calendar.NOVEMBER:
					this.addMonth(new Month(this, Calendar.NOVEMBER));
					break;
				case Calendar.DECEMBER:
					this.addMonth(new Month(this, Calendar.DECEMBER));
					break;
				default:
					break;
			}			
		}
	}
	
	public Integer getYear() {
		return this.year;
	}
	
	public List<Month> getMonths() {
		return this.months;
	}
}
